<?php

namespace app\admin\controller;

use think\Controller;
use think\Cookie;
use think\Session;
use think\Db;

class Base extends Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->isLogin();
    }

    // 查看权限
    public function checkPower($type){
        $admin = Cookie::get('userName');
        $power = Db::name('admin')->alias('a')->join('power p', 'a.id = p.aid')->field('p.padd,p.pdel,p.pcheck,p.pupdate')->where('a.user', $admin)->where('p.pname', $type)->select();
        return $power;
    }

    // 判断有没有登录
    public function isLogin(){
        $admin = Cookie::has('userName');
        if(!$admin || Cookie('isLogin') != 1){
            $this->redirect('admin/User/index', 302);
        }
    }
}
